package cn.dglydrpy.study.j2ee.hdfs.rpc;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;

import java.io.IOException;

/**
 * Rpc Server
 *
 */
public class RpcServer {
    public static void main(String[] args) throws IOException {
        //创建Rpc 服务
        RPC.Builder builder = new RPC.Builder(new Configuration());

        //绑定地址
        builder.setBindAddress("localhost");

        //绑定端口
        builder.setPort(8888);

        //绑定协议
        builder.setProtocol(RpcProtocol.class);

        //调用协议的实现类
        builder.setInstance(new RpcProtocolImpl());

        //创建Rpc服务
        RPC.Server server = builder.build();

        //启动RPC 服务
        server.start();

        System.out.println("服务端启动成功！");

    }
}
